#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int kConcatenationMaxSum(vector<int>& arr, int k) {
	int n = arr.size();
	vector<int> f(n + 1), g(n + 1);
	int maxsum = INT_MIN, minsum = INT_MAX,sum = 0;
	for (int i = 1; i <= n; i++)
	{
		f[i] = max(f[i - 1], 0) + arr[i - 1];
		g[i] = min(g[i - 1], 0) + arr[i - 1];
		maxsum = max(maxsum, f[i]);
		minsum = min(minsum, g[i]);
		sum += arr[i - 1];
	}
	if (k == 1)
		return maxsum;
	else if(k == 2)
		return max(maxsum, sum - minsum);
	else
	{
		int ret = max(maxsum, sum - minsum);
		if(sum > 0)
		ret += sum * (k - 2);
		return ret;
	}
}
int maximumsSplicedArray(vector<int>& nums1, vector<int>& nums2) {
	int n = nums1.size();
	vector<int> diff(n);
	int sum1 = 0, sum2 = 0;
	for (int i = 0; i < n; i++)
	{
		diff[i] = nums2[i] - nums1[i];
		sum1 += nums1[i];
		sum2 += nums2[i];
	}
	vector<int> f(n + 1),g(n + 1);
	int maxf = 0, maxg = 0;
	for (int i = 1; i <= n; i++)
	{
		f[i] = max(0, f[i - 1]) + diff[i - 1];
		g[i] = max(0, g[i - 1]) - diff[i - 1];
		maxf = max(maxf, f[i]);
		maxg = max(maxg, g[i]);
	}
	return max(sum1 + maxf, sum2 + maxg);
}
int main()
{

	return 0;
}